import React from 'react';
import {isNoMoreElement, openMoreWin} from "../../util/common";
class FooterMore extends React.Component {
  constructor(props) {
      super(props);
      this.state = {}
      this.onMoreClick = this.onMoreClick.bind(this);
  }

    onMoreClick = (eid, ebaseid, _moreurl, moreRouteurl) => {
        const { customClickMore} = this.props;
        if(typeof customClickMore === "function")
            customClickMore(eid, ebaseid, _moreurl, moreRouteurl);
        else
            openMoreWin(eid, ebaseid, _moreurl, moreRouteurl);
    }

  render() {
      const { config ,needMore = true} = this.props;
      const { isSetting, item } = config;
      const { eid, header, ebaseid } = item;
      const { toolbar } = header;
      const { more } = toolbar;
      if(more && more.position == "footer") {
          let moreRouteurl = "";
          if(ebaseid == '8' || ebaseid == '7') {
              WeaTools.callApi('/api/portal/customMore/getRouteurl', 'POST', {ebaseid, eid}).then(result => {
                  if(result.status == '200' && result.moreRouteurl){
                      moreRouteurl =  result.moreRouteurl
                  }
              });
          }
          return (
              <div>
                  {more && more.position=='footer' &&  needMore ? (
                      isNoMoreElement(ebaseid) && !moreRouteurl ? '':
                          <a id={`more_${eid}`} href="javascript:void(0);" onClick={() => {this.onMoreClick(eid, ebaseid, more.morehref, moreRouteurl)}}>
                              <img className="img_more" id="imgMore" border="0" src={more.img} title={more.title} alt=''/>
                          </a>
                  ) : ''}
              </div>
          )
      }else{
          return <div/>
      }
  }
}
import { WeaErrorPage, WeaTools } from 'ecCom';
class MyErrorHandler extends React.Component {
  render() {
    const hasErrorMsg = this.props.error && this.props.error !== "";
    return (
      <WeaErrorPage ecId={`${this && this.props && this.props.ecId || ''}_WeaErrorPage@ltlkh4`} msg={hasErrorMsg ? this.props.error:getLabel(385218,"对不起，该页面异常，请联系管理员！")} />
    );
  }
}
FooterMore = WeaTools.tryCatch(React, MyErrorHandler, { error: "" })(FooterMore);
export default FooterMore;
